home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / include / lispeval.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  3.2 KB  |  133 lines

  1. /** \file lispeval.h
  2.  *  Evaluation of expressions.
  3.  *
  4.  */
  5.  
  6. #ifndef __lispeval_h__
  7. #define __lispeval_h__
  8.  
  9. #include "yacasbase.h"
  10. #include "lispobject.h"
  11. #include "lispenvironment.h"
  12.  
  13. /*
  14. void InternalEval(LispEnvironment& aEnvironment, LispPtr& aResult, LispPtr& aExpression);
  15. */
  16.  
  17. class UserStackInformation : public YacasBase
  18. {
  19. public:
  20.     UserStackInformation():
  21.         iRulePrecedence(-1),iSide(0)
  22.     {
  23. #ifdef DEBUG_MODE
  24.         iFileName = "(no file)";
  25.         iLine = 0;
  26. #endif
  27.     }
  28.     LispPtr iOperator;
  29.     LispInt iRulePrecedence;
  30.     LispInt iSide; // 0=pattern, 1=body
  31.  
  32. #ifdef DEBUG_MODE
  33.     LispCharPtr iFileName;
  34.     LispInt iLine;
  35. #endif
  36.     
  37. };
  38.  
  39.  
  40.  
  41. class LispEvaluatorBase : public YacasBase
  42. {
  43. public:
  44.     virtual ~LispEvaluatorBase();
  45.     virtual void Eval(LispEnvironment& aEnvironment, LispPtr& aResult, LispPtr& aExpression)=0;
  46.     virtual void ResetStack();
  47.     virtual UserStackInformation& StackInformation();
  48.     virtual void ShowStack(LispEnvironment& aEnvironment, LispOutput& aOutput);
  49. private:
  50.     UserStackInformation iBasicInfo;
  51. };
  52.  
  53.  
  54. class BasicEvaluator : public LispEvaluatorBase
  55. {
  56. public:
  57.     virtual void Eval(LispEnvironment& aEnvironment, LispPtr& aResult, LispPtr& aExpression);
  58. };
  59.  
  60. class TracedEvaluator : public BasicEvaluator
  61. {
  62. public:
  63.     virtual void Eval(LispEnvironment& aEnvironment, LispPtr& aResult, LispPtr& aExpression);
  64.     virtual void Interact();
  65. };
  66.  
  67.  
  68. class TracedStackEvaluator : public BasicEvaluator
  69. {
  70. public:
  71.     ~TracedStackEvaluator();
  72.     virtual void Eval(LispEnvironment& aEnvironment, LispPtr& aResult, LispPtr& aExpression);
  73.     virtual void ResetStack();
  74.     virtual UserStackInformation& StackInformation();
  75.     virtual void ShowStack(LispEnvironment& aEnvironment, LispOutput& aOutput);
  76.  
  77. private:
  78.     void PushFrame();
  79.     void PopFrame();
  80. private:
  81.     CArrayGrower<UserStackInformation*> objs;
  82. };
  83.  
  84.  
  85.  
  86. /* GetUserFunction : get user function, possibly loading the required
  87.    files to read in the function definition */
  88. LispUserFunction* GetUserFunction(LispEnvironment& aEnvironment,
  89.                                   LispPtr* subList);
  90.  
  91.  
  92. /* Tracing functions */
  93. void TraceShowEnter(LispEnvironment& aEnvironment,
  94.                     LispPtr& aExpression);
  95. void TraceShowLeave(LispEnvironment& aEnvironment, LispPtr& aResult,
  96.                     LispPtr& aExpression);
  97. void TraceShowArg(LispEnvironment& aEnvironment,LispPtr& aParam,
  98.                   LispPtr& aValue);
  99.  
  100.  
  101. void ShowExpression(LispString& outString, LispEnvironment& aEnvironment,
  102.                     LispPtr& aExpression);
  103.  
  104.  
  105. class YacasDebuggerBase : public YacasBase
  106. {
  107. public:
  108.     virtual ~YacasDebuggerBase();
  109.     virtual void Start() = 0;
  110.     virtual void Finish() = 0;
  111.     virtual void Enter(LispEnvironment& aEnvironment, 
  112.                        LispPtr& aExpression) = 0;
  113.     virtual void Leave(LispEnvironment& aEnvironment, LispPtr& aResult,
  114.                        LispPtr& aExpression) = 0;
  115. };
  116.  
  117. class DefaultDebugger : public YacasDebuggerBase
  118. {
  119. public:
  120.     virtual void Start();
  121.     virtual void Finish();
  122.     virtual void Enter(LispEnvironment& aEnvironment, 
  123.                        LispPtr& aExpression);
  124.     virtual void Leave(LispEnvironment& aEnvironment, LispPtr& aResult,
  125.                        LispPtr& aExpression);
  126. };
  127.  
  128.  
  129. #endif
  130.  
  131.  
  132.  
  133.